home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
tclMotif-1.4
/
programs
/
progDH4.3
< prev
next >
Wrap
Text File
|
1995-06-29
|
3KB
|
120 lines
# Dan Hellers program 4.3, p 99
# show pixmaps, allow them to change colour, file selection to
# change bitmaps. When doing this, use pixmaps in eg
# /usr/lib/X11/bitmaps
global pixmap
set pixmap xlogo32
xtAppInitialize -class Program
xmMainWindow .main managed -scrollBarDisplayPolicy as_needed \
-scrollingPolicy automatic
# mainWindow .main
xmLabel .main.label managed -labelType pixmap -labelPixmap $pixmap
# I am not supporting simple menu functions, so do this the long way
# top menu bar
xmMenuBar .main.menuBar managed
xmCascadeButton .main.menuBar.file managed \
-labelString File \
-mnemonic F
xmCascadeButton .main.menuBar.edit managed \
-labelString Edit \
-mnemonic E
xmCascadeButton .main.menuBar.help managed \
-labelString Help \
-mnemonic H
# file pulldown
xmPulldownMenu .main.menuBar.fileMenu
xmPushButton .main.menuBar.fileMenu.new managed \
-labelString "New..." \
-mnemonic N
xmPushButton .main.menuBar.fileMenu.quit managed \
-labelString Quit \
-mnemonic Q
.main.menuBar.file setValues -subMenuId .main.menuBar.fileMenu
# callbacks for file menu
.main.menuBar.fileMenu.quit activateCallback "exit 0"
.main.menuBar.fileMenu.new activateCallback fileDialog
# edit pulldown
xmPulldownMenu .main.menuBar.editMenu
xmToggleButton .main.menuBar.editMenu.black managed \
-labelString Black \
-mnemonic k
xmToggleButton .main.menuBar.editMenu.red managed \
-labelString Red \
-mnemonic R
xmToggleButton .main.menuBar.editMenu.green managed\
-labelString Green \
-mnemonic G
xmToggleButton .main.menuBar.editMenu.blue managed \
-labelString Blue \
-mnemonic B
# .main.menuBar.editMenu.black setValues -set True
.main.menuBar.edit setValues -subMenuId .main.menuBar.editMenu
# callbacks for edit menu
# note we use disarm rather than armed, because changed value
# not set till then
.main.menuBar.editMenu.black disarmCallback "change_colour black"
.main.menuBar.editMenu.red disarmCallback "change_colour red"
.main.menuBar.editMenu.green disarmCallback "change_colour green"
.main.menuBar.editMenu.blue disarmCallback "change_colour blue"
.main.menuBar.editMenu setValues -radioBehavior True \
-radioAlwaysOne True
# help pulldown
xmPulldownMenu .main.menuBar.helpMenu managed
xmPushButton .main.menuBar.helpMenu.help managed \
-labelString Help \
-mnemonic H
.main.menuBar.help setValues -subMenuId .main.menuBar.helpMenu
.main.menuBar setValues -menuHelpWidget .main.menuBar.help
.main setValues -workWindow .main.label \
-menuBar .main.menuBar
proc change_colour {colour} {
global isSet
global pixmap
.main.menuBar.editMenu.$colour getValues -set isSet
if {$isSet == "true"} {
.main.label setValues -foreground $colour
.main.label setValues -labelPixmap $pixmap
}
}
proc fileDialog {} {
# does this command already exist - else create it
if {[llength [info commands .fileDialog]] > 0} {
.fileDialog manageChild
} else {
xmFileSelectionDialog .fileDialog managed
.fileDialog okCallback load_pixmap
.fileDialog cancelCallback ".fileDialog unmanageChild"
}
}
proc load_pixmap {} {
global selection
global pixmap
.fileDialog getValues -dirSpec selection
.main.label setValues -labelPixmap $selection
set pixmap $selection
}
. realizeWidget
. mainLoop